package com.ny.controller;

import com.ny.entity.Reservations;
import com.ny.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class ReservationController {

    @Autowired
    private ReservationService reservationService;
    @RequestMapping("/reservations")
    public String  reservation(Model model){
        model.addAttribute("reservationList", reservationService.findAllReservations());
        return "reservations";
    }
    @GetMapping("/user/myReservations")
    public String myReservations(Model model) {
        // 获取所有预约记录
        List<Reservations> allReservations = reservationService.findAllReservations();
        // 将预约记录列表添加到模型，不需要转换为Map
        model.addAttribute("reservationList", allReservations);

        return "myReservations";
    }
}
